class Player
	def play_turn(warrior)
		if warrior.health < 3
			if !warrior.feel(:left).enemy? && !warrior.feel(:right).enemy? && !warrior.feel(:forward).enemy? && !warrior.feel(:backward).enemy?
				warrior.rest!
			else
				warrior.walk!(:backward)
			end
		else
			# add your code here
			captive = false
			warrior.listen.each{|item|
				if item.to_s() == "Captive"
					captive = true
					direction = warrior.direction_of(item)
					if warrior.feel(direction).empty?
						warrior.walk!(direction)
					elsif warrior.feel(direction).captive?
						warrior.rescue!(direction)
					elsif warrior.feel(:left).enemy?
						warrior.bind!(:left)
					elsif warrior.feel(:right).enemy?
						warrior.bind!(:right)
					elsif warrior.feel(:forward).enemy?
						warrior.attack!
					end
					break
				end
			}
			if(!captive)
				if warrior.feel(warrior.direction_of_stairs).enemy?
					warrior.attack!(warrior.direction_of_stairs)
				else
					warrior.walk!(warrior.direction_of_stairs)
				end
			end
		end
	  end
 end
